﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/_LayoutAdmin.cshtml";
}

<head>
    <title>主页</title>
    <link href="~/BootstrapSouce/css/bootstrap.min.css" rel="stylesheet" />
    <script src="~/BootstrapSouce/js/jquery.min.js"></script>
    <script src="~/BootstrapSouce/js/bootstrap.min.js"></script>
    <link href="~/CSS/Admin_Index.css" rel="stylesheet" />
    <script>
        
        $(document).ready(function () {
            GetArticlescrap(1);
            GetRated(1);
            GetPosition(1);
            GetInterview(1);
            //用户下拉框
            $.ajax({
                url: 'http://localhost:32132/api/Values/GetUsers',
                type: 'get',
                success: function (d) {
                    var p = jQuery.parseJSON(d);
                    $(p).each(function (i, obj) {
                        var h1 = '<option value="' + obj.Login_Id + '">' + obj.Login_Name + '</option>';
                        $("#Sel_Art").append(h1);
                    })
                }
            })
        })
        var size = 5;
        //面试经验文章分页显示
        function GetArticlescrap(i)
        {
            var Uid = $("#Sel_Art").val();
            $.ajax({
                url: 'http://localhost:32132/api/Values/GetArticlescrap?pageindex='+i+'&&pagesize='+size+'&&UserId='+Uid,
                type: 'get',
                data: { "pageindex": i, "pagesize": size, "UserId": Uid },
                success: function (d) {
                    var p = jQuery.parseJSON(d);
                    $("#Arttbody").empty();
                    $("#pagenext").empty();
                    $(p.Data).each(function (i, obj) {
                        
                        var h1 = "<tr><td>" + obj.Articlescrap_Id + "</td><td>" + obj.Articlescrap_Title + "</td><td>" + obj.Articlescrap_date + "</td><td>" + obj.Login_Nickname + "</td><td><a  href='/Admin/ArtDetails?" + obj.Articlescrap_Id + "'>查看</a>&nbsp;<a href='#' onclick='Delart(" + obj.Articlescrap_Id + ")' >删除</a></td></tr>";
                        $("#Arttbody").append(h1);
                    })
                    var a1 = '<a href="#" class="btn btn-default btn-sm" onclick="GetArticlescrap(1);">首页</a>&nbsp;&nbsp;';
                    if (p.PageIndex - 1 > 0) {
                        var a2 = '<a href="#" class="btn btn-default btn-sm" onclick="GetArticlescrap(' + (p.PageIndex - 1) + ');">上一页</a>&nbsp;&nbsp;';
                    }
                    if (p.PageCount % size == 0) {
                        if (p.PageIndex < (p.PageCount / size)) {
                            var a3 = '<a href="#" class="btn btn-default btn-sm" onclick="GetArticlescrap(' + (p.PageIndex + 1) + ');">下一页</a>&nbsp;&nbsp;';
                        }
                    }
                    else {
                        if (p.PageIndex < (p.PageCount / size)) {
                            var a3 = '<a href="#" class="btn btn-default btn-sm" onclick="GetArticlescrap(' + (p.PageIndex + 1) + ');">下一页</a>&nbsp;&nbsp;';
                        }
                    }
                    if (p.PageCount % size != 0) {
                        var a4 = '<a href="#" class="btn btn-default btn-sm" onclick="GetArticlescrap(' + Math.floor(p.PageCount / size + 1) + ');">尾页</a>';
                    }
                    else {
                        var a4 = '<a href="#" class="btn btn-default btn-sm" onclick="GetArticlescrap(' + Math.floor(p.PageCount / size) + ');">尾页</a>';
                    }
                    $("#pagenext").append(a1);
                    $("#pagenext").append(a2);
                    $("#pagenext").append(a3);
                    $("#pagenext").append(a4);
                }
            })
        
        }
        //面试经验文章删除
        function Delart(id)
        {
            if (confirm('确认删除吗?')) {
                $.ajax({
                    type: "get",
                    url: "http://localhost:32132/api/Values/DelArticlescrap?id=" + id,
                    data: {
                        "id": id,
                    },
                    success: function (d) {
                        if (d > 0) {
                            location.href = "/Admin/Index";
                        }
                        else {
                            alert("删除失败");
                        }
                    }
                });
            }
        }
        //评价信息管理
        function GetRated(i) {
            var Ratedname = $("#Ratedname").val();
            $.ajax({
                url: 'http://localhost:32132/api/Values/ShowRated?pageindex=' + i + '&pagesize=' + size,
                type: 'get',
                data: { "pageindex": i, "pagesize": size, "Ratedname": Ratedname },
                success: function (d) {
                    var p = jQuery.parseJSON(d);
                    $("#RatedInfo").empty();
                    $("#pagenext1").empty();
                    $(p.Data).each(function (i, obj) {
                        var h1 = "<tr><td>" + obj.Login_Nickname + "</td><td>" + obj.Rated_Content + "</td><td>" + obj.Rated_Request + "</td><td>" + obj.Articlescrap_Title + "</td><td><a href='#' onclick='DelRate(" + obj.Rated_Id + ")' >删除</a></td></tr>";
                        $("#RatedInfo").append(h1);
                    })
                    var a1 = '<a href="#" class="btn btn-default btn-sm" onclick="GetRated(1);">首页</a>&nbsp;&nbsp;';
                    if (p.PageIndex - 1 > 0) {
                        var a2 = '<a href="#" class="btn btn-default btn-sm" onclick="GetRated(' + (p.PageIndex - 1) + ');">上一页</a>&nbsp;&nbsp;';
                    }
                    if (p.PageCount % size == 0) {
                        if (p.PageIndex < (p.PageCount / size)) {
                            var a3 = '<a href="#" class="btn btn-default btn-sm" onclick="GetRated(' + (p.PageIndex + 1) + ');">下一页</a>&nbsp;&nbsp;';
                        }
                    }
                    else {
                        if (p.PageIndex < (p.PageCount / size)) {
                            var a3 = '<a href="#" class="btn btn-default btn-sm" onclick="GetRated(' + (p.PageIndex + 1) + ');">下一页</a>&nbsp;&nbsp;';
                        }
                    }
                    if (p.PageCount % size != 0) {
                        var a4 = '<a href="#" class="btn btn-default btn-sm" onclick="GetRated(' + Math.floor(p.PageCount / size + 1) + ');">尾页</a>';
                    }
                    else {
                        var a4 = '<a href="#" class="btn btn-default btn-sm" onclick="GetRated(' + Math.floor(p.PageCount / size) + ');">尾页</a>';
                    }
                    $("#pagenext1").append(a1);
                    $("#pagenext1").append(a2);
                    $("#pagenext1").append(a3);
                    $("#pagenext1").append(a4);
                }
            })

        }
        //删除评价信息
        function DelRate(id) {
            if (confirm('确认删除吗?')) {
                $.ajax({
                    type: "post",
                    url: "http://localhost:32132/api/Values/DelRated?id=" + id ,
                    data: {
                        "id": id,
                    },
                    success: function (d) {
                        if (d > 0) {
                            location.href = "/Admin/Index";
                        }
                        else {
                            alert("删除失败");
                        }
                    }
                });
            }
        }
        //职位信息
        function GetPosition(i) {
            
            $.ajax({
                url: 'http://localhost:32132/api/Values/ShowPosition?pageindex=' + i + '&pagesize=' + size,
                type: 'get',
                data: { "pageindex": i, "pagesize": size,  },
                success: function (d) {
                    var p = jQuery.parseJSON(d);
                    $("#PositionInfo").empty();
                    $("#pagenext2").empty();
                    $(p.Data).each(function (i, obj) {
                        var h1 = "<tr><td>" + obj.position_id + "</td><td>" + obj.position_name + "</td><td><a href='#' onclick='DelRate(" + obj.position_id + ")' >删除</a></td></tr>";
                        $("#PositionInfo").append(h1);
                    })
                    var a1 = '<a href="#" class="btn btn-default btn-sm" onclick="page(1);">首页</a>&nbsp;&nbsp;';
                    if (d.PageIndex - 1 > 0) {
                        var a2 = '<a href="#" class="btn btn-default btn-sm" onclick="page(' + (d.PageIndex - 1) + ');">上一页</a>&nbsp;&nbsp;';
                    }
                    if (d.PageCount % size == 0) {
                        if (d.PageIndex < (d.PageCount / size)) {
                            var a3 = '<a href="#" class="btn btn-default btn-sm" onclick="page(' + (d.PageIndex + 1) + ');">下一页</a>&nbsp;&nbsp;';
                        }
                    }
                    else {
                        if (d.PageIndex < (d.PageCount / size)) {
                            var a3 = '<a href="#" class="btn btn-default btn-sm" onclick="page(' + (d.PageIndex + 1) + ');">下一页</a>&nbsp;&nbsp;';
                        }
                    }
                    if (d.PageCount % size != 0) {
                        var a4 = '<a href="#" class="btn btn-default btn-sm" onclick="page(' + Math.floor(d.PageCount / size + 1) + ');">尾页</a>';
                    }
                    else {
                        var a4 = '<a href="#" class="btn btn-default btn-sm" onclick="page(' + Math.floor(d.PageCount / size) + ');">尾页</a>';
                    }
                    $("#pagenext2").append(a1);
                    $("#pagenext2").append(a2);
                    $("#pagenext2").append(a3);
                    $("#pagenext2").append(a4);
                }
            })

        }
        //删除评价信息
        function DelPosition(id) {
            if (confirm('确认删除吗?')) {
                $.ajax({
                    type: "post",
                    url: "http://localhost:32132/api/Values/DelPosition?id=" + id,
                    data: {
                        "id": id,
                    },
                    success: function (d) {
                        if (d > 0) {
                            location.href = "/Admin/Index";
                        }
                        else {
                            alert("删除失败");
                        }
                    }
                });
            }
        }
       

        //面试表显示
        function GetInterview(i) {
            var name = $("#name").val();
            $.ajax({
                url: 'http://localhost:32132/api/values/GetInter?pageindex='+i+'&&pagesize='+size,
                type: 'get',
                data: { "pageindex": i, "pagesize": size, "interview_data": name, },
                success: function (d) {
                    var p = jQuery.parseJSON(d);
                    $("#InterviewInfo").empty();
                    $("#pagenext3").empty();
                    $(p.Data).each(function (i, obj) {
                        var str = " <tr> <td>  " + obj.interview_id + "</td> ";
                        str += "  <td>  " + obj.position_name + "</td> ";
                        str += "  <td>  " + obj.interview_data + " </td>  ";
                        str += "  <td>  " + obj.interview_tapes + " </td> ";
                        str += "  <td>  " + obj.interview_image + " </td> ";
                        str += "  <td>  " + obj.interview_attached + " </td> ";
                        str += "  <td>  " + obj.Login_Name + " </td>  ";
                        str += "  <td>  " + obj.interview_integrity + " </td> ";
                        str += "  <td>  " + obj.Rated_Content + " </td> ";
                        str += "  <td>  <a href='#' onclick='DelInter(" + obj.interview_id + ")' >删除</a> </td>  </tr>";
                        $("#InterviewInfo").append(str);
                    })
                    var a1 = '<a href="#" class="btn btn-default btn-sm" onclick="GetInterview(1);">首页</a>&nbsp;&nbsp;';
                    if (p.PageIndex - 1 > 0) {
                        var a2 = '<a href="#" class="btn btn-default btn-sm" onclick="GetInterview(' + (p.PageIndex - 1) + ');">上一页</a>&nbsp;&nbsp;';
                    }
                    if (p.PageCount % size == 0) {
                        if (d.PageIndex < (p.PageCount / size)) {
                            var a3 = '<a href="#" class="btn btn-default btn-sm" onclick="GetInterview(' + (p.PageIndex + 1) + ');">下一页</a>&nbsp;&nbsp;';
                        }
                    }
                    else {
                        if (p.PageIndex < (p.PageCount / size)) {
                            var a3 = '<a href="#" class="btn btn-default btn-sm" onclick="GetInterview(' + (p.PageIndex + 1) + ');">下一页</a>&nbsp;&nbsp;';
                        }
                    }
                    if (p.PageCount % size != 0) {
                        var a4 = '<a href="#" class="btn btn-default btn-sm" onclick="page(' + Math.floor(p.PageCount / size + 1) + ');">尾页</a>';
                    }
                    else {
                        var a4 = '<a href="#" class="btn btn-default btn-sm" onclick="page(' + Math.floor(p.PageCount / size) + ');">尾页</a>';
                    }
                    $("#pagenext3").append(a1);
                    $("#pagenext3").append(a2);
                    $("#pagenext3").append(a3);
                    $("#pagenext3").append(a4);
                }
            })

        }
        function sele() {
            GetInterview(1);
        }
        //删除面试表信息
        function DelInter(id)
        {
            alert(id);
            if (confirm('确认删除吗?')) {
                $.ajax({
                    type: "get",
                    url: "http://localhost:32132/api/Values/DelInter?id="+id,
                    data: {
                        "id": id,
                    },
                    success: function (d) {
                        if (d > 0) {
                            location.href = "/Admin/Index";
                        }
                        else {
                            alert("删除失败");
                        }
                    }
                });
            }
        }
    </script>
</head>
<body>
    <div id="left_Menu_ul" style="width: 17%;">
        <ul id="myTab" class="nav nav-tabs">
            <li class="active"> <a href="#home" data-toggle="tab">面试经验文章管理</a> </li>
            <li> <a href="#ios" data-toggle="tab">评论信息后台管理</a> </li>
            <li> <a href="#dabai" data-toggle="tab">职位信息后台管理</a> </li>
            <li> <a href="#xbai" data-toggle="tab">面试信息后台管理</a> </li>
            <li> <a href="#user" data-toggle="tab">用户信息后台管理</a> </li>
        </ul>
    </div>
    <div id="right_Div_ul">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade in active" id="home">
                <select id="Sel_Art" class="btn btn-default btn-sm" style="width:200px;margin-bottom:10px;margin-right:10px">
                    <option value="0">请选择</option>
                </select><input class="btn btn-default btn-sm" onclick="GetArticlescrap(1)" style="margin-bottom:10px" type="button" value="搜索" />
               <table class="table table-bordered table-hover">
                   <thead>
                       <tr>
                           <td>文章编号</td>
                           <td>文章标题</td>
                           <td>上传时间</td>
                           <td>上传人</td>
                           <td>操作</td>
                       </tr>
                   </thead>
                   <tbody id="Arttbody"></tbody>
               </table>
                <div id="pagenext" style="text-align:center"></div>
            </div>
            <div class="tab-pane fade" id="ios">
                <input type="text" id="Ratedname" /><input class="btn btn-default btn-sm" onclick="GetRated(1)" style="margin-bottom:10px" type="button" value="搜索" />
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <td>评论人</td>
                            <td>评论内容</td>
                            <td>追加内容</td>
                            <td>评论文章</td>
                            <td>操作</td>
                        </tr>
                    </thead>
                    <tbody id="RatedInfo"></tbody>
                </table>
                <div id="pagenext1" style="text-align:center"></div>
            </div>
            <div class="tab-pane fade" id="dabai">
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <td>职位编号</td>
                            <td>职位名称</td>
                            <td>操作</td>
                        </tr>
                    </thead>
                    <tbody id="PositionInfo"></tbody>
                </table>
                <div id="pagenext2" style="text-align:center"></div>
            </div>
            <div class="tab-pane fade" id="xbai">
                
                <input class="se" type="text" id="name" name="name" placeholder="请输入"  />
                <input id="Su" type="button" value="查询" class="search-btn" onclick="sele()" />


                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <td>面试编号</td>
                            <td>面试职位外键</td>
                            <td>发布日期</td>
                            <td>面试录音</td>
                            <td>试题图片</td>
                            <td>面试附加</td>                     
                            <td>上传人用户</td>
                            <td>消耗积分</td>
                            <td>评价</td>                           
                            <td>操作</td>
                        </tr>
                    </thead>
                    <tbody id="InterviewInfo"></tbody>
                </table>
                <div id="pagenext3" style="text-align:center"></div>
            </div>
          
        </div>

    </div>
</body>

